home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 142
/
Volume 142 Oct 17 2011 - Damaged.iso
/
Games
/
rapid-fire.swf
/
scripts
/
__Packages
/
Target.as
< prev
next >
Wrap
Text File
|
2011-10-17
|
7KB
|
196 lines
class Target extends MovieClip
{
function Target()
{
super();
this.Init();
}
function Init()
{
var _loc1_ = this;
var _loc2_ = _root;
switch(_loc1_.type)
{
case 1:
_loc1_.attachMovie("copter_mc","part",1,{_x:0,_y:-47});
_loc1_.dy = Math.random() >= 0.5 ? - (Math.random() * 1.5 + 1) : Math.random() * 1.5 + 1;
_loc1_.dx = Math.random() >= 0.5 ? - (Math.random() * 0.5 + 0.5) : Math.random() * 0.5 + 0.5;
_loc1_._x = Math.random() * 425;
_loc1_._y = _loc1_.dy <= 0 ? 442 : -32;
break;
case 2:
_loc1_.part = _loc1_.attachMovie("balloon_mc","part",1,{_x:-16,_y:-78});
_loc1_.part.hotspot.onPress = function()
{
var _loc1_ = this;
var _loc2_ = _root;
_loc1_._parent._parent._parent.attachMovie("balloon_pop_mc","b_pop_" + _loc2_.mc_counter,_loc2_.mc_counter,{color_index:_loc1_._parent._currentframe,_x:_loc1_._parent._parent._x - 16,_y:_loc1_._parent._parent._y - 78});
_loc2_.mc_counter += 1;
_loc1_._parent._parent.Fall();
};
_loc1_.sinus = 0;
_loc1_.dy = - (Math.random() * 1.5 + 1);
_loc1_.dx = Math.random() * 0.5 + 0.7;
_loc1_._x = Math.random() * 425;
_loc1_._y = 462;
break;
case 3:
_loc1_.part = _loc1_.attachMovie("spring_mc","part",1);
_loc1_.sinus = 0;
_loc1_.dx = Math.random() >= 0.5 ? - (Math.random() + 1) : Math.random() + 1;
_loc1_.dy = - (Math.random() * 1.5 + 1);
_loc1_.ay = 100 + Math.random() * 250;
_loc1_._x = _loc1_.dx <= 0 ? 505 : -80;
_loc1_._y = 442;
break;
case 4:
_loc1_.attachMovie("rubber_mc","part",1);
_loc1_._x = Math.random() * 425;
_loc1_._y = -40;
_loc1_.ay = Math.random() * 300 + 45;
break;
case 5:
_loc1_.part = _loc1_.attachMovie("wings_mc","part",1);
_loc1_.dx = Math.random() >= 0.5 ? - (Math.random() + 2) : Math.random() + 2;
_loc1_._x = _loc1_.dx <= 0 ? 515 : -90;
_loc1_.dy = Math.random() * 2 - 1;
_loc1_._y = Math.random() * 200 + 100;
}
_loc1_.hot_spot.onPress = function()
{
var _loc1_ = this;
var _loc2_ = _root;
_loc1_._parent.dx_shot = _loc2_._xmouse - _loc1_._parent._x - _loc2_.targets_holder_mc._x;
_loc1_._parent.dy_shot = _loc2_._ymouse - _loc1_._parent._y;
_loc1_._parent.Die();
};
}
function Update()
{
var _loc1_ = this;
switch(_loc1_.type)
{
case 1:
_loc1_._x += _loc1_.dx;
_loc1_._y += _loc1_.dy;
break;
case 2:
_loc1_._x += Math.sin(_loc1_.sinus) * _loc1_.dx;
_loc1_.sinus += 0.05;
_loc1_._y += _loc1_.dy;
break;
case 3:
_loc1_._x += _loc1_.dx;
_loc1_._y = 380 - Math.abs(Math.sin(_loc1_.sinus) * _loc1_.ay);
_loc1_.part._rotation = Math.sin(_loc1_.sinus * 2) * _loc1_.dx * 7;
_loc1_.sinus += 0.03;
if(_loc1_._x > 510 || _loc1_._x < -85)
{
_loc1_.removeMovieClip();
}
break;
case 4:
_loc1_.dy = _loc1_.ay - _loc1_._y;
_loc1_._y += _loc1_.dy / 10;
if(Math.abs(_loc1_._y - _loc1_.ay) < 0.5)
{
_loc1_.ay = -50;
}
break;
case 5:
_loc1_._x += _loc1_.dx;
_loc1_._y += _loc1_.dy;
_loc1_._y -= (_loc1_.part._currentframe - 11) / 10;
if(_loc1_._x > 520 || _loc1_._x < -95)
{
_loc1_.removeMovieClip();
}
break;
case 6:
_loc1_._y += _loc1_.dy;
_loc1_.dy += 0.3;
}
if(_loc1_.dy > 0)
{
if(_loc1_._y > 442)
{
_loc1_.removeMovieClip();
}
}
else if(_loc1_._y < -43)
{
_loc1_.removeMovieClip();
}
}
function Fall()
{
var _loc1_ = this;
_loc1_.part.removeMovieClip();
_loc1_.dy = 0;
_loc1_.type = 6;
}
function Die()
{
var _loc1_ = _root;
var _loc2_ = this;
if(_loc2_.type == 2)
{
_loc2_._parent.attachMovie("balloon_fly_mc","b_fly_" + _loc1_.mc_counter,_loc1_.mc_counter,{dx:_loc2_.dx,dy:_loc2_.dy,sinus:_loc2_.sinus,color_index:_loc2_.part._currentframe,_x:_loc2_._x - 16,_y:_loc2_._y - 78});
_loc1_.mc_counter += 1;
}
var shot_radius = Math.sqrt(_loc2_.dx_shot * _loc2_.dx_shot + _loc2_.dy_shot * _loc2_.dy_shot);
if(shot_radius <= 3)
{
_loc1_.bulls_eye_snd.start(0,1);
_loc1_.perfect_combo += 1;
var points = 20 * _loc1_.perfect_combo;
}
else
{
_loc1_.perfect_combo = 0;
var points = Math.floor((1 - (shot_radius - 3) / 23) * 19) + 1;
}
_loc1_.score += points;
_loc1_.goal -= points;
_loc1_.goal = _loc1_.goal >= 0 ? _loc1_.goal : 0;
if(_loc1_.goal == 0 && !_loc1_.level_win)
{
_loc1_.got_goal_snd.start(0,1);
var _loc3_ = 0;
while(_loc3_ < 6)
{
_loc1_["goal_num_" + _loc3_]._visible = false;
_loc3_ = _loc3_ + 1;
}
_loc1_.attachMovie("got_goal_mc","got_goal_mc",_loc1_.mc_counter,{_x:491,_y:304});
_loc1_.mc_counter += 1;
_loc1_.level_win = true;
}
_loc1_.ShowScore();
var t_shot = _loc2_._parent.attachMovie("target_shot_mc","t_shot_" + _loc1_.mc_counter,_loc1_.mc_counter - 5000,{_x:_loc2_._x,_y:_loc2_._y});
_loc1_.mc_counter += 1;
switch(_loc2_.type)
{
case 1:
case 3:
_loc2_._parent.attachMovie("debris_mc","debris_" + _loc1_.mc_counter,_loc1_.mc_counter,{type:_loc2_.type,x:_loc2_._x,y:_loc2_._y,r:_loc2_.part._rotation});
_loc1_.mc_counter += 1;
break;
case 4:
_loc2_._parent.attachMovie("rubber_band","r_band_" + _loc1_.mc_counter,_loc1_.mc_counter,{_x:_loc2_._x,_y:_loc2_._y});
_loc1_.mc_counter += 1;
break;
case 5:
_loc2_._parent.attachMovie("debris_mc","debris_" + _loc1_.mc_counter,_loc1_.mc_counter,{type:5,x:_loc2_._x,y:_loc2_._y});
_loc1_.mc_counter += 1;
_loc2_._parent.attachMovie("debris_mc","debris_" + _loc1_.mc_counter,_loc1_.mc_counter,{type:6,x:_loc2_._x,y:_loc2_._y});
_loc1_.mc_counter += 1;
}
t_shot.shot_dot._x = _loc2_.dx_shot;
t_shot.shot_dot._y = _loc2_.dy_shot;
_loc2_._parent.attachMovie("points_mc","pts_" + _loc1_.mc_counter,_loc1_.mc_counter,{_x:_loc2_._x,_y:_loc2_._y - 36,points:points});
_loc1_.mc_counter += 1;
_loc2_.removeMovieClip();
}
}